package dao.impl;

import dao.Top10SessionDao;
import domain.Top10Session;
import domain.UserClickCount;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import util.JDBCUtils;

import java.util.List;

public class Top10SessionDaoImpl implements Top10SessionDao {
    private JdbcTemplate template = new JdbcTemplate(JDBCUtils.getDataSource());
    @Override
    public List<Top10Session> SelectSessionClickCount() {
        String sql = "SELECT categoryid,SUM(clickCount) clickCount FROM top10_session GROUP BY categoryid";
        List<Top10Session> query = template.query(sql, new BeanPropertyRowMapper<Top10Session>(Top10Session.class));
        return query;
    }
}
